package com.eagle.functioninterface;

import org.junit.Test;

import java.util.function.*;

/**
 * 这类函数式接口是: input+To+output+Function
 * <p>
 * int , double,long 三种基本类型两两转换
 * {@link java.util.function.IntToLongFunction}
 * {@link java.util.function.IntToDoubleFunction}
 * {@link java.util.function.DoubleToIntFunction}
 * {@link java.util.function.DoubleToLongFunction}
 * {@link java.util.function.LongToDoubleFunction}
 * {@link java.util.function.LongToIntFunction}
 *
 * @author qinlinsen
 */
public class InputToOutputFunctionTest16 {
    @Test
    public void testIntToLongFunction() {
        IntToLongFunction f = x -> x + 4;
        final long result = f.applyAsLong(4);
        System.out.println(result);
    }

    @Test
    public void testIntToDoubleFunction() {
        IntToDoubleFunction f = x -> x + 4;
        final double result = f.applyAsDouble(4);
        System.out.println(result);
    }

    @Test
    public void testDoubleToIntFunction() {
        DoubleToIntFunction f = x -> (int) x + 3;
        final int result = f.applyAsInt(5);
        System.out.println(result);
    }

    @Test
    public void testDoubleToLongFunction() {
        DoubleToLongFunction f = x -> (long) x + 4;
        final long result = f.applyAsLong(4);
        System.out.println(result);
    }

    @Test
    public void testLongToIntFunction() {
        LongToIntFunction f = x -> (int) x + 4;
        final int result = f.applyAsInt(4);
        System.out.println(result);
    }

    @Test
    public void testLongToDoubleFunction() {
        LongToDoubleFunction f = x -> x + 2;
        final double result = f.applyAsDouble(6);
        System.out.println(result);
    }
}
